package com.qf.mybatisDynamicSqlDemo.until;

import cn.hutool.core.util.RandomUtil;
import com.qf.mybatisDynamicSqlDemo.entity.Book;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 刘欣
 * @createTime 2022/12/22 20:55
 * @description
 */
public class RanDomeBookUntil {
    private static String str = "qwertyuioopasdfghjklzxcvbnm";

    public static Book getBook() {
        Book book = new Book();
        book.setName(getBookName());
        book.setAuthor(getBookauthor());
        book.setPublish(getBookPublish());
        book.setSort(getSort());
        return book;
    }

    public static String getBookName() {
        return RandomUtil.randomString(str, 5);
    }

    public static String getBookauthor() {
        return RandomUtil.randomString(str, 10);
    }

    public static String getBookPublish() {
        return RandomUtil.randomString(str, 10);
    }

    public static Integer getSort() {
        return RandomUtil.randomInt(9999);

    }

    public static List<Book> getBooksBatch(Integer num) {
        List<Book> books = new ArrayList<>();
        for (Integer i = 0; i < num; i++) {
            books.add(getBook());
        }
        return books;
    }
}
